<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>

    <title th:text="#{cas.login.pagetitle}">CAS Interrupt View</title>
    <link href="../../static/css/cas.css" rel="stylesheet" th:remove="tag" />

    <script th:inline="javascript" th:if="${interrupt.autoRedirect}">
        /*<![CDATA[*/

        var autoRedirect = /*[[${interrupt.autoRedirect}]]*/;
        var emptyLinks = /*[[${#maps.isEmpty(interrupt.links)}]]*/;

        if (autoRedirect && !emptyLinks) {

            var link = /*[[${interrupt.links.values().iterator().next()}]]*/;
            var redirectTimeout = /*[[${interrupt.autoRedirectAfterSeconds}]]*/;

            setTimeout(function () {
                window.location = link;
            }, redirectTimeout <= 0 ? 0 : redirectTimeout * 1000);

        }
        /*]]>*/
    </script>
</head>

<body>
<main role="main" class="container mt-3 mb-3">
    <div layout:fragment="content">
        <h1 th:text="#{screen.interrupt.title}">Authentication Interrupt</h1>
        <p th:utext="#{screen.interrupt.message(${principal.id})}">The authentication flow has been interrupted. CAS has
            not yet established a single sign-on session for <strong>{0}</strong>.</p>

        <div th:if="${interrupt.message}" class="alert alert-info">
            <p th:utext="${interrupt.message}">interrupt.message</p>
            <br/>

            <div th:if="${interrupt.links}">
                <a class="btn btn-success"
                   th:each="link : ${interrupt.links}"
                   th:text="${link.key}"
                   th:href="${link.value}">link.key</a>
            </div>
        </div>


        <form method="post" id="fm1" th:if="${not interrupt.block}">
            <div class="form-group text-center">
                <div class="col-12">
                    <input type="hidden" name="execution" th:value="${flowExecutionKey}"/>
                    <input type="hidden" name="_eventId" value="proceed"/>
                    <input class="btn btn-primary"
                           name="proceed"
                           accesskey="l"
                           th:value="#{screen.interrupt.btn.proceed}"
                           value="Proceed"
                           type="submit"/>
                    &nbsp;<a class="btn btn-primary" id="login" name="login"
                             th:href="${service?.id} ?: @{/login}" th:text="#{screen.error.page.loginagain}">Login Again</a>
                </div>
            </div>
        </form>

        <div th:if="${interrupt.block}" class="text-center">
            <a class="btn btn-warning" id="cancel" name="cancel" th:href="@{/login}"
               th:text="#{screen.interrupt.btn.cancel}">Cancel</a>
        </div>
    </div>
</main>
</body>

</html>
